<!-- 业务算法弹窗表单模板 -->
<style>
/* 弹窗样式 */
.xc_modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.xc_modal-overlay.active {
    display: flex;
}

.xc_modal-container {
    width: 90%;
    max-width: 750px;
    max-height: 90vh;
    background: white;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: xc_modalSlideIn 0.3s ease;
}

@keyframes xc_modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xc_modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
    border-radius: 6px 6px 0 0;
}

.xc_modal-title {
    font-size: 15px;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.xc_modal-title i {
    color: #3b82f6;
    font-size: 14px;
}

.xc_modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #6b7280;
    font-size: 16px;
}

.xc_modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.xc_modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

.xc_modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #fafafa;
}

/* 表单样式 */
.xc_form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.xc_form-col {
    flex: 1;
}

.xc_form-col.full {
    flex: 0 0 100%;
}

.xc_form-group {
    margin-bottom: 10px;
}

.xc_form-label {
    display: block;
    font-size: 12px;
    color: #606266;
    margin-bottom: 4px;
}

.xc_form-label .required {
    color: #f56c6c;
    margin-left: 2px;
}

.xc_form-input,
.xc_form-select,
.xc_form-textarea {
    width: 100%;
    padding: 0 10px;
    font-size: 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    transition: border-color 0.2s;
    background: white;
}

.xc_form-input {
    height: 30px;
}

.xc_form-select {
    height: 30px;
}

.xc_form-select[multiple] {
    height: auto;
    min-height: 150px;
    padding: 4px;
}

.xc_form-select[multiple] option {
    padding: 3px 8px;
    margin: 1px 0;
    border-radius: 2px;
    font-size: 11px;
}

.xc_form-textarea {
    min-height: 50px;
    padding: 6px 10px;
    resize: vertical;
    line-height: 1.4;
}

.xc_form-input:focus,
.xc_form-select:focus,
.xc_form-textarea:focus {
    border-color: #3b82f6;
    outline: none;
}

.xc_form-input:disabled,
.xc_form-select:disabled {
    background: #f5f7fa;
    color: #909399;
    cursor: not-allowed;
}

/* 流程图样式 */
.xc_flow-hint {
    background: linear-gradient(90deg, #e8f5f1 0%, #f0f9f6 100%);
    border-left: 3px solid #169F85;
    padding: 8px 12px;
    margin-bottom: 14px;
    border-radius: 4px;
    font-size: 12px;
    color: #169F85;
}

.xc_flow-hint i {
    margin-right: 4px;
}

.xc_flow-step {
    background: #fafbfc;
    border: 1px solid #e4e7ed;
    border-radius: 5px;
    padding: 10px 12px;
    margin: 8px 0;
    transition: all 0.2s;
}

.xc_flow-step:hover {
    border-color: #169F85;
    box-shadow: 0 2px 8px rgba(22, 159, 133, 0.1);
}

.xc_step-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.xc_step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #169F85 0%, #14b89a 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-right: 8px;
}

.xc_step-title {
    font-size: 12px;
    font-weight: 600;
    color: #303133;
}

.xc_step-body {
    padding-left: 32px;
}

.xc_flow-arrow {
    text-align: center;
    margin: 4px 0;
    color: #169F85;
    font-size: 16px;
}

/* 按钮样式 */
.xc_btn {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.xc_btn-cancel {
    background: white;
    color: #606266;
    border-color: #dcdfe6;
}

.xc_btn-cancel:hover {
    background: #f5f7fa;
    color: #374151;
}

.xc_btn-submit {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.xc_btn-submit:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.xc_btn-submit:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

.xc_loading-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: xc_spin 0.6s linear infinite;
}

@keyframes xc_spin {
    to { transform: rotate(360deg); }
}
</style>

<!-- 弹窗HTML -->
<div id="flowModal" class="xc_modal-overlay">
    <div class="xc_modal-container">
        <div class="xc_modal-header">
            <div class="xc_modal-title">
                <i class="fa fa-sitemap"></i>
                <span id="flowModalTitle">业务算法</span>
            </div>
            <button class="xc_modal-close" onclick="closeFlowModal()">
                <i class="fa fa-times"></i>
            </button>
        </div>
        <div class="xc_modal-body">
            <!-- 基本信息 -->
            <div class="xc_form-row">
                <div class="xc_form-col">
                    <div class="xc_form-group">
                        <label class="xc_form-label">算法编号<span class="required">*</span></label>
                        <input type="text" id="flow_code" class="xc_form-input" disabled>
                    </div>
                </div>
                <div class="xc_form-col">
                    <div class="xc_form-group">
                        <label class="xc_form-label">算法名称<span class="required">*</span></label>
                        <input type="text" id="flow_name" class="xc_form-input" placeholder="请输入算法名称">
                    </div>
                </div>
            </div>

            <div class="xc_form-row">
                <div class="xc_form-col full">
                    <div class="xc_form-group">
                        <label class="xc_form-label">算法模式<span class="required">*</span></label>
                        <select id="flow_mode" class="xc_form-select">
                            <option value="0">请选择算法模式</option>
                        </select>
                    </div>
                </div>
            </div>

            <!-- 流程图容器 -->
            <div id="flow_diagram" style="display:none;">
                <div id="flow_mode_name" class="xc_flow-hint"></div>

                <!-- 检测算法 -->
                <div id="flow_box_detect" class="xc_flow-step" style="display:none;">
                    <div class="xc_step-header">
                        <div class="xc_step-icon"><i class="fa fa-search"></i></div>
                        <div class="xc_step-title">检测算法</div>
                    </div>
                    <div class="xc_step-body">
                        <select id="select_algorithm_detect" class="xc_form-select">
                            <option value="0">选择检测算法</option>
                        </select>
                        <div id="flow_box_detect_class" class="xc_step-target" style="display:none; margin-top:8px;">
                            <select id="select_detect_class_name" class="xc_form-select" multiple>
                                <option value="0">选择检测目标</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div id="arrow_after_detect" class="xc_flow-arrow" style="display:none;">
                    <i class="fa fa-angle-down"></i>
                </div>

                <!-- 二次检测算法 -->
                <div id="flow_box_detect2" class="xc_flow-step" style="display:none;">
                    <div class="xc_step-header">
                        <div class="xc_step-icon"><i class="fa fa-search-plus"></i></div>
                        <div class="xc_step-title">二次检测</div>
                    </div>
                    <div class="xc_step-body">
                        <select id="select_algorithm_detect2" class="xc_form-select">
                            <option value="0">选择检测算法</option>
                        </select>
                        <div id="flow_box_detect2_class" class="xc_step-target" style="display:none; margin-top:8px;">
                            <select id="select_detect2_class_name" class="xc_form-select" multiple>
                                <option value="0">选择检测目标</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div id="arrow_after_detect2" class="xc_flow-arrow" style="display:none;">
                    <i class="fa fa-angle-down"></i>
                </div>

                <!-- 分类算法 -->
                <div id="flow_box_classify" class="xc_flow-step" style="display:none;">
                    <div class="xc_step-header">
                        <div class="xc_step-icon"><i class="fa fa-sitemap"></i></div>
                        <div class="xc_step-title">分类算法</div>
                    </div>
                    <div class="xc_step-body">
                        <select id="select_algorithm_classify" class="xc_form-select">
                            <option value="0">选择分类算法</option>
                        </select>
                        <div id="flow_box_classify_class" class="xc_step-target" style="display:none; margin-top:8px;">
                            <select id="select_classify_class_name" class="xc_form-select" multiple>
                                <option value="0">选择分类目标</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div id="arrow_after_classify" class="xc_flow-arrow" style="display:none;">
                    <i class="fa fa-angle-down"></i>
                </div>

                <!-- 特征算法 -->
                <div id="flow_box_track" class="xc_flow-step" style="display:none;">
                    <div class="xc_step-header">
                        <div class="xc_step-icon"><i class="fa fa-fingerprint"></i></div>
                        <div class="xc_step-title">特征算法</div>
                    </div>
                    <div class="xc_step-body">
                        <select id="select_algorithm_track" class="xc_form-select">
                            <option value="0">选择特征算法</option>
                        </select>
                    </div>
                </div>

                <div id="arrow_after_track" class="xc_flow-arrow" style="display:none;">
                    <i class="fa fa-angle-down"></i>
                </div>

                <!-- 行为算法 -->
                <div id="flow_box_behaviour" class="xc_flow-step" style="display:none;">
                    <div class="xc_step-header">
                        <div class="xc_step-icon"><i class="fa fa-cogs"></i></div>
                        <div class="xc_step-title">行为算法</div>
                    </div>
                    <div class="xc_step-body">
                        <select id="select_behaviour" class="xc_form-select">
                            <option value="0">选择行为算法</option>
                        </select>
                    </div>
                </div>
            </div>

            <!-- 运行配置 -->
            <div id="flow_config" style="display:none; margin-top:14px;">
                <div class="xc_form-row">
                    <div class="xc_form-col">
                        <div class="xc_form-group">
                            <label class="xc_form-label">分析进程<span class="required">*</span></label>
                            <input type="number" id="deploy_process_index" class="xc_form-input" value="0" min="0">
                        </div>
                    </div>
                    <div class="xc_form-col">
                        <div class="xc_form-group">
                            <label class="xc_form-label">最大实例数<span class="required">*</span></label>
                            <input type="number" id="max_concurrency" class="xc_form-input" value="1" min="1">
                        </div>
                    </div>
                    <div class="xc_form-col">
                        <div class="xc_form-group">
                            <label class="xc_form-label">并发单元长度<span class="required">*</span></label>
                            <input type="number" id="concurrency_unit_length" class="xc_form-input" value="1" min="1">
                        </div>
                    </div>
                </div>

                <div class="xc_form-row">
                    <div class="xc_form-col full">
                        <div class="xc_form-group">
                            <label class="xc_form-label">备注</label>
                            <textarea id="flow_remark" class="xc_form-textarea" placeholder="请输入备注信息"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="xc_modal-footer">
            <button class="xc_btn xc_btn-cancel" onclick="closeFlowModal()">取消</button>
            <button class="xc_btn xc_btn-submit" id="flowSubmitBtn" onclick="submitFlowForm()">
                <span id="submitBtnText">提交</span>
            </button>
        </div>
    </div>
</div>
